const { v4: uuidv4 } = require('uuid');
const fs = require('fs');
const path = require('path');
const md5 = require('md5');

const createMid = () => {
    try {
        const mIdPath = path.join(__dirname, '../.m_id')
        // 不存在写m_id
        if (!fs.existsSync(mIdPath)) {
            console.log('生成mid');
            fs.writeFileSync(mIdPath, uuidv4());
        } else {
            console.log('已有mid，不需要生成！');
        }
    } catch (_) {
        console.log(_);
    }
}
const cerateRoomId = () => {
    return md5(Date.now());
}
module.exports = {
    cerateRoomId,
    createMid
};